<?php

namespace App\Service\Cruise\Mission;

use App\Models\Cruise\CruiseOrderModel;
use App\Models\Cruise\CruiseTemplateModel;
use App\Models\OpenShop\SiteLocation\OpenShopSiteLocationModel;
use App\Service\BaseService;

class MallInputService extends CruiseOrderInputBaseService
{
    private ?CruiseOrderModel          $cruiseOrderModel;
    private ?OpenShopSiteLocationModel $openShopSiteLocationModel;
    private int                        $userId;

    public function __construct(int $siteLocationId, int $userId = 0)
    {
        $this->userId = $userId;

        $this->openShopSiteLocationModel = OpenShopSiteLocationModel::query()
            ->where('id', $siteLocationId)
            ->first();

        if (!$this->openShopSiteLocationModel) {
            BaseService::throwErr("选址信息不存在");
        }

        $this->cruiseOrderModel = CruiseOrderModel::query()->where('id', $this->openShopSiteLocationModel->cruiseOrderId)->first();
        if (!$this->cruiseOrderModel) {
            BaseService::throwErr("不存在任务ID:{$this->openShopSiteLocationModel->cruiseOrderId}");
        }

        parent::__construct(
            $this->openShopSiteLocationModel->cruiseOrderId, CruiseTemplateModel::TYPE_99,
            $this->cruiseOrderModel->cruiseTemplateRel->sysTemplate ?? 0
        );
    }

    /**
     * 初始化表单信息
     * @return void
     */
    public function initOrderInput(): void
    {
        parent::baseInitOrderInput(132);
    }

    protected function saveUserContentJson(string $field, $value): void
    {
        // TODO: Implement saveUserContentJson() method.
    }


    /**
     * 获得表单信息
     * @return array
     */
    public function getInputObjectFill(): array
    {
        return parent::baseGetInputObjectFill(true);
    }

    protected function submitOrder(): void
    {
        // TODO: Implement submitOrder() method.
    }

    protected function audit(array $data): void
    {
        // TODO: Implement audit() method.
    }
}
